# Copyright 2023 Ant Group Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

package(default_visibility = ["//visibility:public"])

cc_library(
    name = "operator",
    srcs = ["operator.cc"],
    hdrs = ["operator.h"],
    deps = [
        ":exec",
        "@com_github_gflags_gflags//:gflags",
    ],
)

cc_library(
    name = "registry",
    srcs = ["registry.cc"],
    hdrs = ["registry.h"],
    deps = [
        ":operator",
        "@yacl//yacl/base:exception",
    ],
)

cc_library(
    name = "tensor_table",
    srcs = ["tensor_table.cc"],
    hdrs = ["tensor_table.h"],
    deps = [
        "//engine/core:tensor",
        "@yacl//yacl/base:exception",
    ],
)

cc_library(
    name = "exec",
    srcs = ["exec.cc"],
    hdrs = ["exec.h"],
    deps = [
        ":session",
        ":tensor_table",
        "//api:core_cc_proto",
        "//engine/util:tensor_util",
    ],
)

cc_library(
    name = "executor",
    srcs = ["executor.cc"],
    hdrs = ["executor.h"],
    deps = [
        ":registry",
    ],
)

cc_library(
    name = "session",
    srcs = ["session.cc"],
    hdrs = ["session.h"],
    deps = [
        ":party_info",
        ":tensor_table",
        "//api:common_cc_proto",
        "//api:engine_cc_proto",
        "//engine/datasource:datasource_adaptor_mgr",
        "//engine/datasource:router",
        "//engine/util:logging",
        "//engine/util:prometheus_monitor",
        "//engine/util:psi_detail_logger",
        "//engine/exe:flags",
        "@com_github_openssl_openssl//:openssl",
        "@spulib//libspu/core:config",
        "@spulib//libspu/core:context",
        "@spulib//libspu/device:symbol_table",
        "@spulib//libspu/mpc:factory",
        "@yacl//yacl/link",
    ],
)

cc_library(
    name = "session_manager",
    srcs = ["session_manager.cc"],
    hdrs = ["session_manager.h"],
    deps = [
        ":session",
        "//engine/link:listener",
    ],
)

cc_test(
    name = "session_manager_test",
    srcs = ["session_manager_test.cc"],
    deps = [
        ":session_manager",
        "//engine/operator:test_util",
        "@com_google_googletest//:gtest_main",
    ],
)

cc_library(
    name = "party_info",
    srcs = ["party_info.cc"],
    hdrs = ["party_info.h"],
    deps = [
        "//api:engine_cc_proto",
        "@yacl//yacl/base:exception",
    ],
)

cc_test(
    name = "party_info_test",
    srcs = ["party_info_test.cc"],
    deps = [
        ":party_info",
        "//engine/operator:test_util",
        "@com_google_googletest//:gtest_main",
    ],
)
